from connect_mysql import Connect

class function_box(Connect):

    def login_sql(self,user,password):
        # 登录的sql语句以及执行sql后的结果
        login_verify_sql = '''
            SELECT user_name , pass_word FROM qq_login WHERE\
            user_name = %s and pass_word = %s            
            '''
        self.cursor.execute(login_verify_sql,(user, password))
        result = self.cursor.fetchone()
        return result 

    def reset_pwd_sql(self, user, password):
        # 更改密码的sql语句
        reset_password_sql = '''
        UPDATE qq_login SET pass_word = %s where user_name = %s
        '''
        result = self.cursor.execute(reset_password_sql,(password, user))
        self.conn.commit()
        return result

    def register_sql(self, user):
        # 注册使用的sql语句
        register_account_sql = '''
        select user_name from qq_login where user_name = %s
        '''
        self.cursor.execute(register_account_sql,(user,))
        result = self.cursor.fetchone()
        return result
    
    def index_info(self):
        '''首页的sql'''
        index_sql = 'select * from company where id=%s '

        self.cursor.execute(index_sql)

        result = self.cursor.fetchone()

if __name__ == "__main__":
    
    x = function_box()
    xi = x.index_info()

    print(xi)